package com.itqn.service.Impl;

import com.itqn.dao.Impl.MemberDaoImpl;
import com.itqn.dao.MemberDao;
import com.itqn.pojo.Member;
import com.itqn.pojo.PageBean;
import com.itqn.service.MemberService;

public class MemberServiceImpl implements MemberService {
    MemberDao memberDao=new MemberDaoImpl();

    @Override
    public void updatestatic(Member member) throws Exception {
        memberDao.updateStatic(member);
    }

    @Override
    public Member findById(int id) throws Exception {
        return memberDao.findById(id);
    }

    @Override
    public int addProduct(Member member) throws Exception {
        return memberDao.addProduct(member);
    }

    @Override
    public int updateMember(Member member) {
        return memberDao.updateMember(member);
    }

    @Override
    public PageBean<Member> query(String name, String cartNumber, Integer totalAmount, Integer pageSize, Integer page) throws Exception {
        PageBean pb = new PageBean();
        // 封装商品集合
        pb.setList(memberDao.query(name, cartNumber, totalAmount, pageSize, page));
        // 封装总条数
        Integer totalCount = memberDao.totalCount(name, cartNumber, totalAmount);
        pb.setTotalCount(totalCount);
        // 封装总页数
        pb.setPageCount(totalCount % pageSize == 0 ? totalCount / pageSize : (totalCount / pageSize + 1));
        return pb;
    }
}
